package com.google.code.coma.gui.util;

import com.google.code.coma.domain.Type;
import javafx.scene.image.Image;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Dominik Strasser, dominikstr@gmail.com
 */
public class ImageUtil {
	private static Map<String, Image> images = new HashMap<String, Image>();

	public static Image getImage(Type type) {
		return load(type.name().toLowerCase());
	}

	public static Image getComputerOKImage() {
		return load("computer_ok");
	}
	
	public static Image getComputerImage() {
		return load("computer_created");
	}

	public static Image getOrderImage() {
		return load("order");
	}

	private static Image load(String name) {
		if (images.containsKey(name)) {
			return images.get(name);
		}
		Image i = new Image(ImageUtil.class.getResourceAsStream("/images/" + name + ".png"));
		images.put(name, i);
		return i;
	}
}
